<template>
  <el-dialog
    v-model="visible"
    title="公告详情"
    width="800px"
    :close-on-click-modal="false"
    :show-close="true"
    @close="handleClose"
    class="announcement-dialog"
  >
    <div class="dialog-container">
      <div class="announcement-content">
        <h3 class="title">{{ announcement.title }}</h3>
        <div class="meta">
          <span class="time">
            <i class="el-icon-time"></i>
            {{ announcement.createTime }}
          </span>
        </div>
        <div class="content-box">
          <div class="content">{{ announcement.content }}</div>
        </div>
      </div>
    </div>
    <template #footer>
      <div class="dialog-footer">
        <el-button  text type="info" @click="handleClose" class="confirm-btn">
          已读
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { ref } from 'vue'

const visible = ref(false)
const announcement = ref({})
function toggle(data) {
    visible.value = true
    announcement.value = data
}

function handleClose() {
    // 可做清理
    visible.value = false
}
defineExpose({
    toggle
})

</script>

<style scoped>
.announcement-dialog {
  border-radius: 12px;
  overflow: hidden;
}

.dialog-container {
  padding: 20px;
}

.title {
  font-size: 22px;
  font-weight: 600;
  color: #333;
  margin-bottom: 15px;
  text-align: center;
}

.meta {
  text-align: center;
  margin-bottom: 25px;
}

.time {
  color: #999;
  font-size: 14px;
}

.content-box {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
}

.content {
  font-size: 16px;
  line-height: 1.8;
  color: #555;
  white-space: pre-wrap;
}

.dialog-footer {
  text-align: center;
  padding: 10px 0;
}

.confirm-btn {
  padding: 10px 30px;
  border-radius: 20px;
  font-weight: 500;
}

/* 滚动条样式 */
.content-box::-webkit-scrollbar {
  width: 6px;
}

.content-box::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.content-box::-webkit-scrollbar-track {
  background: #f1f1f1;
}
</style>